//
//  HomeTitleButton.swift
//  zyqWeibo
//
//  Created by 张亚琼 on 15/6/28.
//  Copyright © 2015年 张亚琼. All rights reserved.
//

import UIKit

class HomeTitleButton: UIButton {
    
    // 类方法，返回设置之后的button
    class func button(title: String) -> HomeTitleButton {
        let btn = HomeTitleButton()
        btn.setTitleColor(UIColor.blackColor(), forState: UIControlState.Normal)
        btn.titleLabel?.font = UIFont.systemFontOfSize(17.0)
        // 加空格来隔开label和图片
        btn.setTitle(title + " ", forState: UIControlState.Normal)
        btn.setImage(UIImage(named: "navigationbar_arrow_down"), forState: UIControlState.Normal)
        btn.sizeToFit()
        return btn
    }

    override func layoutSubviews() {
        super.layoutSubviews()
        // swift中可以直接赋值
        titleLabel!.frame.origin.x = 0
        imageView!.frame.origin.x = titleLabel!.bounds.width
        
    }

}
